package cn.mst.vrs.job;

import cn.mst.vrs.dal.dataobject.order.OrderDO;
import cn.mst.vrs.dal.mysql.order.OrderMapper;
import com.alibaba.fastjson.JSON;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
@Component
public class ReservationOrderConsumeJob {
    @Resource
    private OrderMapper orderMapper;

    @Scheduled(cron = "0 0/1 * * * ? ")
    public String execute() {
        LocalDateTime now = LocalDateTime.now();
        List<OrderDO> orderDOList = orderMapper.selectOrderNotExpired();
        for (OrderDO orderDO : orderDOList) {
            String extendInfo = orderDO.getExtendInfo();
            Map<String, String> extendInfoMap = JSON.parseObject(extendInfo, HashMap.class);
//            LocalDateTime startedAt = LocalDateTimeUtil.parse(extendInfoMap.get("startedAt"));
//            LocalDateTime endedAt = LocalDateTimeUtil.parse(extendInfoMap.get("endedAt"));
        }
        return null;
    }
}
